package com.dvd.lia.glia001;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import com.dvd.utils.*;
import org.apache.struts.action.*;
import java.util.*;

public class GLIA001Action extends Action{
	
	@Override
	public ActionForward execute(ActionMapping mapping, ActionForm form,
			HttpServletRequest request, HttpServletResponse response)
			throws Exception {
		return this.login(mapping, form, request, response);
	}

	public ActionForward login(ActionMapping mapping, ActionForm form,
			HttpServletRequest request, HttpServletResponse response)
	{
		GLIA001Bean bean = (GLIA001Bean)form;
		String FLoginId = bean.getFLoginId();
		String FPwd =bean.getFPwd();
		GLIA001Model model = new GLIA001Model();
		boolean result=model.searchAdminInfo(FLoginId, FPwd);
		if(result==false)
		{	
			Message message = new Message("","Error","管理者情報存在しません");
			request.setAttribute("Message", message);
			return mapping.getInputForward();
		}
		else
		{
			List<Message> messages = new ArrayList<Message>();
			messages.add(new Message("","[INFO]","管理者情報は成功にログインしました！"));
			request.setAttribute("List<Message>",messages); 
			request.getSession().setAttribute("loginState", "true");
			return new ActionForward("/GDJK001.do?action=paging");
		}
	}
}
